package com.apache.passport.entity;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import com.apache.api.entity.BaseEntity;
import com.apache.tools.StrUtil;

/**
 * description:  用户表
 * @author Hou Dayu 创建时间：2014-12-18  
 * @Copyright(c)2014:
 */
@SuppressWarnings("serial")
public class UctUser extends BaseEntity {

	private String userId;
	private String userEname;
	private String userCname;
	private String userPass;
	private Integer userStatus;
	private String email;
	private String mobile;
	private String regIp;
	private Long createTime;
	//2015年1月28日16:01:47  添加 添加用户删除标示 如果无此值,则uc无法查看当前用户
	private String delStatus;

	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("userId=" + this.userId + ";");
		sb.append("userEname=" + this.userEname + ";");
		sb.append("userCname=" + this.userCname + ";");
		sb.append("userPass=" + this.userPass + ";");
		sb.append("userStatus=" + this.userStatus + ";");
		sb.append("email=" + this.email + ";");
		sb.append("mobile=" + this.mobile + ";");
		sb.append("regIp=" + this.regIp + ";");
		sb.append("createTime=" + this.createTime + ";");
		sb.append("delStatus=" + this.delStatus + ";");
		return sb.toString();
	}

	/**
	 * description:  通过反射获取对象参数
	 * @param user
	 * @param key
	 * @return  
	 * @author Hou Dayu 
	 * @update 2015-1-26
	 */
	public String getValues(UctUser user, String key) {
		Map<String, String> map = new HashMap<String, String>();
		String rtnValue = "";
		String rtnKey = "";
		try {
			Class<? extends UctUser> userCla = user.getClass();
			Field[] fs = userCla.getDeclaredFields();
			for (int i = 0; i < fs.length; i++) {
				Field f = fs[i];
				// 设置些属性是可以访问的
				f.setAccessible(true);
				// 得到此属性的值    
				Object val = f.get(user);
				rtnKey = f.getName();
				if (StrUtil.isEmpty(val)) {
					rtnValue = "";
				} else {
					rtnValue = val.toString();
				}
				map.put(rtnKey, rtnValue);
			}
			rtnValue = map.get(key);
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return rtnValue;
	}

	/**
	 * description:  获取当前对象中所有的key value值
	 * @param user
	 * @return  
	 * @author Hou Dayu 
	 * @update 2015-1-26
	 */
	public Map<String, String> getValues(UctUser user) {
		Map<String, String> map = new HashMap<String, String>();
		String rtnValue = "";
		String rtnKey = "";
		try {
			Class<? extends UctUser> userCla = user.getClass();
			Field[] fs = userCla.getDeclaredFields();
			for (int i = 0; i < fs.length; i++) {
				Field f = fs[i];
				// 设置些属性是可以访问的
				f.setAccessible(true);
				// 得到此属性的值    
				Object val = f.get(user);
				rtnKey = f.getName();
				if (StrUtil.isEmpty(val)) {
					rtnValue = "";
				} else {
					rtnValue = val.toString();
				}
				map.put(rtnKey, rtnValue);
			}
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return map;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserEname() {
		return userEname;
	}

	public void setUserEname(String userEname) {
		this.userEname = userEname;
	}

	public String getUserCname() {
		return userCname;
	}

	public void setUserCname(String userCname) {
		this.userCname = userCname;
	}

	public String getUserPass() {
		return userPass;
	}

	public void setUserPass(String userPass) {
		this.userPass = userPass;
	}

	public Integer getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(Integer userStatus) {
		this.userStatus = userStatus;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getRegIp() {
		return regIp;
	}

	public void setRegIp(String regIp) {
		this.regIp = regIp;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public String getDelStatus() {
		return delStatus;
	}

	public void setDelStatus(String delStatus) {
		this.delStatus = delStatus;
	}

}
